﻿<%@ WebHandler Language="C#" Class="CheckCode" %>

using System;
using System.Web;
using LibVITDA;

public class CheckCode : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        
        string strTenTable, strTenField, strGiaTri, strMaCu, strTrangThai;        
        int strReturnVal = 0;
        strTenTable = context.Request.QueryString.Get("t");
        strTenField = context.Request.QueryString.Get("c");
        strGiaTri = context.Request.QueryString.Get("v");
        strTrangThai = context.Request.QueryString.Get("s");
        strMaCu = context.Request.QueryString.Get("Oldv");

        if (strTenTable != "" && strTenField != "" && strGiaTri != "")
        {
            XuLyKiemTraMa Ch = new XuLyKiemTraMa();

            if (strTrangThai == "Update" && strMaCu == strGiaTri){
                strReturnVal = 0;
            }
            else
            {
                strReturnVal = Ch.CheckExistCode(strTenTable, strTenField, strGiaTri, 0);
            }
        }//end if
        
        context.Response.ContentType = "text/plain";
        context.Response.Write(strReturnVal.ToString());
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}